﻿using Coldairarrow.Business.Base_leasesystem_invoicedetail;
using Coldairarrow.Entity.Base_leasesystem_invoicedetail;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_invoicedetail
{
    /// <summary>
    /// 发票信息控制器
    /// </summary>
    [Route("/Base_leasesystem_invoicedetail/[controller]/[action]")]
    [OpenApiTag("发票信息控制器")]
    public class leasesystem_invoicedetailController : BaseApiController
    {
        #region DI

        public leasesystem_invoicedetailController(Ileasesystem_invoicedetailBusiness leasesystem_invoicedetailBus)
        {
            _leasesystem_invoicedetailBus = leasesystem_invoicedetailBus;
        }

        Ileasesystem_invoicedetailBusiness _leasesystem_invoicedetailBus { get; }

        #endregion

        #region 获取

        /// <summary>
        /// 获取开票记录列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public object GetOpenInvoiceInfo(PageInput<ConditionDTO> input)
        {
            return _leasesystem_invoicedetailBus.GetOpenInvoiceInfo(input);
        }

        [HttpPost]
        public async Task<PageResult<leasesystem_invoicedetail>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_invoicedetailBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<leasesystem_invoicedetail> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_invoicedetailBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 根据发票ID 查询发票所需信息(客户信息，客户银行，服务商信息，服务商银行)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetInvoice_M_S_InID(IdInputDTO input) 
        {
           return _leasesystem_invoicedetailBus.GetInvoice_M_S_InID(input.id);
        }

        /// <summary>
        /// 根据客户id获取发票地址列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetAddressByMID(IdInputDTO input)
        {
            return await _leasesystem_invoicedetailBus.GetAddressByMID(input.id);
        }

        /// <summary>
        /// 查询发票列表数据   代发明细连代发主表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public object GetDataListOver(PageInput<ConditionDTO> input)
        {
            return  _leasesystem_invoicedetailBus.GetDataListOver(input);
        }

        /// <summary>
        /// 根据客户id获取客户、服务商、客户签约信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public object GetInvoiceInfoByMID(IdInputDTO input)
        {
            return _leasesystem_invoicedetailBus.GetInvoiceInfoByMID(input.id);
        }

        /// <summary>
        /// 获取开票审核数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public object GetOpenInvoiceCheck(PageInput<ConditionDTO> input) 
        {
            return _leasesystem_invoicedetailBus.GetOpenInvoiceCheck(input);
        }
        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_invoicedetail data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _leasesystem_invoicedetailBus.AddDataAsync(data);
            }
            else
            {
                await _leasesystem_invoicedetailBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("invoicedetail.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_invoicedetailBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}